from django.db import models
import datetime
# Create your models here.

class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    def __unicode__(self):
        return self.question
    def was_published_today(self):

        return self.pub_date.date == datetime.datetime.today()
    was_published_today.short_description = 'Published today?'


class Choice(models.Model):
    poll = models.ForeignKey(Poll) #looks like foreign key will link this class
#to the class called Poll. I will look up at the models.ForeignKey
# From book:
# Finally, note a relationship is defined, using ForeignKey.
# That tells Django each Choice is related to a single Poll.
# Django supports all the common database relationships:
# many-to-ones, many-to-manys and one-to-ones.
    choice = models.CharField(max_length=200)
    votes = models.IntegerField()
    def __unicode__(self):
        return self.choice
    
    


